<?php
$name = $_POST['name'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$classid = $_POST['classid'];
$link  = @mysql_connect('localhost', 'root', 'root'); //连接数据库
$errno = mysql_errno(); //判断是否连接成功
if (mysql_errno()) {
    die("$errno" . mysql_error());
}
mysql_select_db('boke'); //选择数据库
mysql_set_charset('utf8'); //设置字符集
$sql = "insert into `stu`(`name`,`sex`,`age`,`classid`) values ('$name','$sex','$age','$classid')"; //准备SQL语句
$ss  = mysql_query($sql); //发送SQL语句

if ($ss) {
	echo "<script>alert('添加成功');window.location.href='chaxun.php'</script>";
}else{
	echo "<script>alert('添加失败');window.location.href='chaxun.php'</script>";
}

mysql_close($link);

